package com.hq.ims.data.vo;

import com.hq.authority.utils.AppUtils;
import com.hq.ims.data.config.verification.VdAdd;
import com.hq.ims.data.config.verification.VdEdit;
import com.hq.ims.data.entity.BusForewarningSet;
import com.hq.ims.data.entityenum.EnumBusKey;
import com.hq.ims.data.vo.auth.BaseRowAuthVo;
import com.hq.utils.util.ListUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
import java.util.stream.Collectors;


/**
 * @author 蒋柏平
 * @since 20241011
 */
@Mapper
public interface BusForewarningSetMapstruct {

    BusForewarningSetMapstruct INSTANCE = Mappers.getMapper(BusForewarningSetMapstruct.class);

    //-------------------------------- 转换VO类 --------------------------------

    @Mappings({
    })
    BusForewarningSetVo toBusForewarningSetVo(BusForewarningSet source);

    default List<BusForewarningSetVo> toBusForewarningSetVoList(List<BusForewarningSet> source) {
        if (source == null) {
            return ListUtils.newEmptyList();
        }
        return source.stream().map(this::toBusForewarningSetVo).collect(Collectors.toList());
    }

    //-------------------------------- 以下为自定义类[输出对象] --------------------------------

    @ApiModel(value = "原始对象的扩展类")
    @Data
    class BusForewarningSetVo extends BusForewarningSet {

        @ApiModelProperty(value = "短信内容")
        private String smsContext;
    }

    @ApiModel(value = "行级权限对象")
    @Data
    class BusForewarningSetRowAuthVo extends BaseRowAuthVo {

        //自定义其它行级权限


        //构造函数
        public BusForewarningSetRowAuthVo(BusForewarningSet entity) {
            //当前操作用户ID
            String userId = AppUtils.getUserId();
        }

    }


    //-------------------------------- 以下为自定义类[输入对象] --------------------------------

    @ApiModel(value = "搜索VO")
    @Data
    class PageSearchVo {

        @ApiModelProperty(value = "业务KEY名称")
        private String busKeyTypeName;

    }

    @ApiModel(value = "添加和修改对象")
    @Data
    class SaveVo {

        @NotBlank(message = "数据ID不能为空", groups = {VdEdit.class})
        @ApiModelProperty(value = "数据ID")
        private String busForewarningSetId;

        @NotNull(message = "业务KEY类型不能为空", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "业务KEY类型")
        private EnumBusKey busKeyType;

        @NotNull(message = "时长小时不能为空", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "时长小时")
        private Integer timeHour;

        @NotBlank(message = "短信code不能为空", groups = {VdAdd.class, VdEdit.class})
        @Size(min = 1, max = 255, message = "短信code长度不能超过255", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "短信code")
        private String smsCode;


    }

    //-------------------------------- springboot验证标识 --------------------------------

}
